using System.ComponentModel.DataAnnotations.Schema;
using System.Data.Entity.ModelConfiguration;
using Hostal.Bussines.Entities;

namespace Hostal.Bussines.Repository.Mapping
{
    public class FacturaMap : EntityTypeConfiguration<Factura>
    {
        public FacturaMap()
        {
            // Primary Key
            this.HasKey(t => t.IdFactura);

            // Properties
            this.Property(t => t.IdFactura)
                .HasDatabaseGeneratedOption(DatabaseGeneratedOption.None);

            // Table & Column Mappings
            this.ToTable("Factura");
            this.Property(t => t.IdFactura).HasColumnName("IdFactura");
            this.Property(t => t.Cliente_Id).HasColumnName("Cliente_Id");
            this.Property(t => t.Fecha).HasColumnName("Fecha");
            this.Property(t => t.NFactura).HasColumnName("NFactura");
            this.Property(t => t.SubTotal).HasColumnName("SubTotal");
            this.Property(t => t.Igv).HasColumnName("Igv");
            this.Property(t => t.Total).HasColumnName("Total");

            // Relationships
            this.HasRequired(t => t.Huesped)
                .WithMany(t => t.Facturas)
                .HasForeignKey(d => d.Cliente_Id);

        }
    }
}
